package com.mall.service.impl;

import com.mall.mapper.InvoiceMapper;
import com.mall.po.Invoice;
import com.mall.service.InvoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName InvoiceServiceImpl
 * @Description TODO
 * @action luoliang
 * @Data 2021/1/6 11:22
 * @Version 1.0
 */
@Service
public class InvoiceServiceImpl implements InvoiceService {

    @Autowired
    private InvoiceMapper invoicemapper;

    /**
     * 删除
     * @param deliverid
     * @return
     */
    @Override
    public int deleteByid(Integer deliverid) {
        int i = invoicemapper.deleteByPrimaryKey(deliverid);
        return i;
    }

    /**
     * 添加
     * @param record
     * @return
     */
    @Override
    public int addinsert(Invoice record) {
        int insert = invoicemapper.insert(record);
        return insert;
    }

    /**
     * 查找
     * @param deliverid
     * @return
     */
    @Override
    public Invoice selectByid(Integer deliverid) {
        Invoice invoice = invoicemapper.selectByPrimaryKey(deliverid);
        return invoice;
    }

    /**
     * 修改
     * @param record
     * @return
     */
    @Override
    public int updateInvoice(Invoice record) {

        return invoicemapper.updateByPrimaryKey(record);
    }

    @Override
    public boolean delectByids(Integer[] deliverids) {

        boolean b = invoicemapper.deleteBydeliverids(deliverids);
        return b;
    }

    @Override
    public List<Invoice> selectPage(int page, int pagesize) {
        List<Invoice> invoices = invoicemapper.selectInvoiceBypage((page-1)*pagesize, pagesize);

        return invoices;
    }


}
